<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<script type="text/javascript">
$(function(){
    $('.item01 img').click(function(){
     $.post('',{'name':$(this).attr('value'),'link':$(this).attr('link')},function(data){
    if (data) {
      window.location.href = ''+data+'';
    }
    })
  })
  })
</script>
  <div class="index">
    <div class="f-screen">
      <div class="content-wrap">
        <div class="sub-nav">
          
      <?php foreach ($category_1 as $key => $value): ?>
        <?php if ($key<3): ?>
          <dl>
            <dt><img src="http://static.tianpinwang.com.cn/v1/images/index/sub-icon<?php echo $key+1;?>.png" alt=""><?= Html::encode($value['name'])?></dt>
            <dd>
          
            <?php if ($value['cate_list']): ?>
              <?php foreach ($value['cate_list'] as $k => $value1): ?>
                <?php if ($k<8): ?>
                    <a href="/product/index/?lv1=<?php echo $value1['parent_id']?>&lv2=<?php echo $value1['id']?>"><?= Html::encode($value1['name'])?></a>
                <?php endif ?>
              <?php endforeach ?>
            <?php endif ?>
             
            </dd>
          <!--   <dd class="moreItem">
              <div class="rightArrow <?php if($key == 1){echo "secondRight";}else if($key == 2){echo "thirdRight";}?>">
                <img src="http://static.tianpinwang.com.cn/v1/images/right-icon03.png" alt="">
              </div>
            <?php foreach ($value['cate_list'] as $key2 => $value2): ?>
               <div class="items">
                <h1 class="tt"><?= Html::encode($value2['name']) ?></h1>
                <ul class="list">
                  第三级分类。如有需要可在后台解注释。这里遍历
                  <li><a></a></li>
                </ul>
             
              </div>

         <?php endforeach ?>
            </dd> -->

          </dl>      
        <?php endif ?>    
      <?php endforeach ?>
        </div>
        <div class="scrollBox autoHeight">
          <div class="scrollWraper01 positionr">
        <?php if ($ban): ?>
          <?php foreach ($ban as $key => $value):?>
              <div class="item01">
             <a style="cursor:pointer" target="<?= $value['target']==1?'_black':'_self'?>">
       <img  src="<?=$value['img_url']?>" value="<?=$value['id']?>" link="<?=$value['link']?>" title="<?= $value['name']?>" style="width:<?= $value['width']?>px;height:<?= $value['height']?>px;"/></a>
             </div>
            <?php endforeach ?>
        <?php endif ?>
           
             <!--  <div class="item01"><img src="http://static.tianpinwang.com.cn/v1/images/index/poster01.png" alt=""></div>
            <div class="item01"><img src="http://static.tianpinwang.com.cn/v1/images/index/poster01.png" alt=""></div>
            <div class="item01"><img src="http://static.tianpinwang.com.cn/v1/images/index/poster01.png" alt=""></div>
            <div class="item01"><img src="http://static.tianpinwang.com.cn/v1/images/index/poster01.png" alt=""></div> -->
          </div> 
          <ul class="pagination01"></ul>
          <div class="left01"><img src="http://static.tianpinwang.com.cn/v1/images/left-icon.png" alt=""></div>
          <div class="right01"><img src="http://static.tianpinwang.com.cn/v1/images/right-icon.png" alt=""></div>
        </div>

        <div class="userInfo">
          <div class="countInfo">
            <p>
              <?php if (Yii::$app->user->isGuest): ?>
                <!-- Hi,晚上好 -->
              <?php else:?>
                <font style="margin-left:-31px;">
                  你好，<span class="userName"><?=Yii::$app->user->identity->username?></span>
                </font>
              <?php endif?>
                <!--after login-->
                <!--晚上好，<span class="userName">137***1231</span>-->
            </p>
              <?php if (Yii::$app->user->isGuest): ?>
              <a href="javascript:;" style="margin-left:-13px;">欢迎来到添品网</a>
              <?php else:?>
              <a href="javascript:;" style="margin-left:-13px;">欢迎来到添品网</a>
              <?php endif?>

              <!--after login-->
            <!--<a href="" class="logined">我的账户</a>-->
            <!-- <img src="" alt="" class="userImg"> -->
          </div>


          <div class="tradInfo positionr">

            <?php if (Yii::$app->user->isGuest): ?>
              <a href="/site/login" class="beforeLogin firstBtn"><i class="iconfont icon-denglu"></i>登录</a>
              <a href="/site/register" class="beforeLogin secondBtn"><i class="iconfont icon-zhuce"></i>立即注册</a>
            <?php else :?>
              
              <?php if ($count): ?>
                  <?php foreach ($count as $key => $v): ?>
                    <a href="/order?s=<?=$key?>" style='color: #363636'>
                      <dl class="logined">
                        <dt><?=Html::encode($v['num'])?></dt>
                        <dd><?=Html::encode($v['name'])?></dd>
                      </dl>
                    </a>
                  <?php endforeach ?>
              <?php endif ?>

            <?php endif ?>
          </div>

          <div class="news">
            <p class="">公告 <a href="/post" class="right">查看更多</a></p>
            <ul>

            <?php if ($notice): ?>
              <?php foreach ($notice as $key => $value): ?>
                <li>
                  <a href="<?= Url::toRoute(['post/about/', 'id' => $value->id]);?>">
                    <?= Html::encode($value->title) ?>
                  </a>
                </li>
              <?php endforeach ?>
            <?php endif ?>

            </ul>
          </div>
        </div>

        <div class="subInfo autoHeight">
            <!-- <div class="item serveTime left">
                <p class="tt0">工作时间 8:30~22:00</p>
                <h1 class="txt0">添品网专业客服团队</h1>
            </div>
            <div class="item left">
                <div class="kefu">
                    <h1 class="shopGuide left"><img src="http://static.tianpinwang.com.cn/v1/images/shop-icon.png" alt=""/>金牌导购</h1>
                    <a href="<?= Url::toRoute(['product/index/', 'lv1' => 72])?>"><img src="http://static.tianpinwang.com.cn/v1/images/kefu.png.png" alt=""/>食品添加剂</a>
                    <a href="<?= Url::toRoute(['product/index/', 'lv1' => 95])?>"><img src="http://static.tianpinwang.com.cn/v1/images/kefu.png.png" alt=""/>食品配料</a>
                    <a href="<?= Url::toRoute(['product/index/', 'lv1' => 96])?>"><img src="http://static.tianpinwang.com.cn/v1/images/kefu.png.png" alt=""/>食品调味料</a>
                </div>
                <div>
                    <h1 class="customService left"><img src="http://static.tianpinwang.com.cn/v1/images/shop-icon.png" alt=""/>售后处理</h1>
                    <a href=""><img src="http://static.tianpinwang.com.cn/v1/images/kefu.png.png" alt=""/>查件<span style="color: #fff">占位符</span></a>
                    <a href=""><img src="http://static.tianpinwang.com.cn/v1/images/kefu.png.png" alt=""/>退换货</a>
                </div>
            </div>
            <div class="item right complaintPhone">
                <a href="/help/7"><img src="http://static.tianpinwang.com.cn/v1/images/kefu.png.png" alt=""/>联系我们</a>
                <p class="txt2">客服热线：<?=Html::encode($this->params['w_config']['contact_tel'])?></p>
            </div>

            <div class="item right complaintTxt" >
                <a href="javascript:;"><img src="http://static.tianpinwang.com.cn/v1/images/yuyin.png" alt=""/>投诉与建议</a>
                <p class="txt1">你的满意是我们不懈的追求！</p>
            </div> -->
            <ul>
              <li><img src="http://static.tianpinwang.com.cn/v1/images/index/subInfoIcon1.png" alt=""><span>震撼低价 杜绝回扣</span></li>
              <li><img src="http://static.tianpinwang.com.cn/v1/images/index/subInfoIcon2.png" alt=""><span>厂商直供 正品保障</span></li>
              <li><img src="http://static.tianpinwang.com.cn/v1/images/index/subInfoIcon3.png" alt=""><span>专业技术 贴心服务</span></li>
              <li><img src="http://static.tianpinwang.com.cn/v1/images/index/subInfoIcon4.png" alt=""><span>品类齐全 一站购齐</span></li>
            </ul>
        </div>
      </div>
    </div>

    <!-- <div class="limitTime content-wrap">
      <h1 class="topInfo">
          <span class="tt">限时促销</span><span class="time">time</span>
          <span class="right nextTime inlineBlock">下期预告 <img src="http://static.tianpinwang.com.cn/v1/images/right-icon01.png" alt=""/></span>
      </h1>
      <ul class="list01">
          <li>
              <div class="img">
                  <img src="" alt=""/>
              </div>
              <p class="name">起酥油</p>
              <p class="introduct">金牌产品，面粉稳定必备</p>
              <p class="price">￥26.00/公斤 <del>￥34.00/公斤</del></p>
              <span class="inlineBlock discount">7.5折</span>
          </li>
      </ul>
    </div> -->

    <!-- <div class="limitTime content-wrap">

      <h1 class="topInfo">
        <span class="tt">下期预告</span><span>,5月10号9点开始</span><span class="time">time</span>
        <span class="right nextTime inlineBlock">返回抢购 <img src="http://static.tianpinwang.com.cn/v1/images/right-icon01.png" alt=""/></span>
      </h1>
      <ul class="list01">
        
        <li>
          <div class="img">
            <img src="" alt=""/>
          </div>
          <p class="name">起酥油</p>
          <p class="introduct">金牌产品，面粉稳定必备</p>
          <p class="price">￥26.00/公斤 <del>￥34.00/公斤</del></p>
          <span class="inlineBlock discount">7.5折</span>
        </li>

      </ul>
    </div> -->

  <div class="goodsLists">
      <div class="content-wrap">
<?php foreach ($category_1 as $key => $value): ?>

    <div class="goodsList">
      <h1 class="topInfo">
          <span class="tt"><?=Html::encode($value['name'])?></span>
          <a href="/product?lv1=<?=Html::encode($value['id'])?>">
            <span class="right nextTime inlineBlock">查看更多
              <img src="http://static.tianpinwang.com.cn/v1/images/right-icon02.png"/>
            </span>
          </a>
      </h1>
      <div class="lists">
          <div class="list01 left">
                <div class="img">
                  <!-- <img src="http://static.tianpinwang.com.cn/v1/images/goods001.png" alt=""/>
                    <h1 class="tt01"><?=Html::encode($value['name'])?></h1>
                    <p class="txt01">食物组合黄金之本</p> -->
                  <?php if ($key == 0): ?>
                    <img src="http://static.tianpinwang.com.cn/v1/images/index/index11.jpg" alt=""/>
                  <?php elseif($key == 1):?>
                    <img src="http://static.tianpinwang.com.cn/v1/images/index/index22.jpg" alt=""/>
                  <?php else: ?>
                    <img src="http://static.tianpinwang.com.cn/v1/images/index/index33.jpg" alt=""/>
                  <?php endif ?>
                    
                    
                </div>
              <div class="category">
                <h1 class="tt"><span>热销分类</span></h1>
                <ul>

                  <?php if ($value['cate_list']): ?>
                    <?php foreach ($value['cate_list'] as $key1 => $v): ?>
                        <?php if ($key1<7): ?>
                          <li>
                            <a href="/product/index/?lv1=72&lv2=<?=$v['id']?>"><?=Html::encode($v['name'])?></a>
                          </li>
                        <?php endif ?>
                    <?php endforeach ?>
                  <?php endif ?>
                  
                </ul>
                <ul>
                  <?php if ($value['cate_list']): ?>
                    <?php foreach ($value['cate_list'] as $key1 => $v): ?>
                        <?php if ($key1>=7): ?>
                          <li>
                            <a href="/product/index/?lv1=72&lv2=<?=$v['id']?>"><?=Html::encode($v['name'])?></a>
                          </li>
                        <?php endif ?>
                    <?php endforeach ?>
                  <?php endif ?>
                </ul>
            </div>
          </div>
  <div class="list02 left">
      <ul>
        <?php if ($value['pro_list']): ?>
          <?php foreach ($value['pro_list'] as $k => $v): ?>
              <?php if ($k<8): ?>
                  <li>
                    <a href="<?= Url::toRoute(['product/'.$v['id']]);?>">
                      <div class="img">
                        <img src="<?=Html::encode($v['img_url'])?>" alt="">
                      </div>
                      <p class="name" value = '<?=Html::encode($v['name'])?>'>
                      <?=Html::encode((strlen($v['name'])>30)?mb_substr($v['name'],0,9,'utf-8').'...':$v['name'])?>
                      </p>
                    </a> 
                    <p class="price">
                      <span>￥</span><?=Html::encode($v['product_price'])?>
                      <span>/<?=Html::encode($v['price_unit'])?></span>
                    </p>
                    <p class="purchaseNum">买家数：<span><?=Html::encode($v['sale_user']?$v['sale_user']:'0')?></span>人</p>
                      <p class="sold">已售：
                      <span><?=Html::encode($v['sale_sum']?$v['sale_sum']:"0")?></span><?=Html::encode($v['price_unit'])?></p>
                  </li> 
              <?php endif ?>
          <?php endforeach ?>
        <?php endif ?>
      </ul>
  </div>
  <div class="list03 left">
    <ul>
      <?php if ($brand_list): ?>
        <?php foreach ($brand_list as $key2 => $val): ?>
          <?php if ($key2<12*($key+1) && $key2>=12*$key): ?>
             <li>
              <a href="/product/index/?bid=<?=$val['id']?>"><?=Html::encode($val['name'])?></a>
            </li>
          <?php endif ?>
        <?php endforeach ?>
      <?php endif ?>
    </ul>
  </div>
  </div>

        </div>
<?php endforeach ?>

          </div>

      </div>
  </div>

<?php
$this->registerJsFile('http://static.tianpinwang.com.cn/v1/js/sliderInfinite.js');
?>
<?php $this->beginBlock('footer_js') ?>
   $(function(){
//      轮播图
      $.slider({
        scrollContainer: '.scrollBox',
        scrollWraper: '.scrollWraper01',
        pre: '.right01',
        next: '.left01',
        scrollItem: '.item01',
        speed: 600,
        animateStyle: 'easeOutCirc',
        scrollPagination: '.pagination01',
        currentPagination: 'current',
        loop: true,
        loopDuration: 5000,
        resetpagination: true,
        paginations: '.pagination01 li'
      });
      $('.scrollBox').on('mouseenter',function(){
        $('.left01').add($('.right01')).fadeIn(200);
      }).on('mouseleave',function(){
        $('.left01').add($('.right01')).fadeOut(200);
      });



//      更多分类
      $('.sub-nav').children('dl').on('mouseenter',function(){
        $(this).addClass('hover').children('.moreItem').css('display','block');
      }).on('mouseleave',function(){
        $(this).removeClass('hover').children('.moreItem').css('display','none');
      });

      $('#lv1_nav a').eq(0).attr('class','cur');

    })
<?php $this->endBlock() ?>  
<?php $this->registerJs($this->blocks['footer_js'], \yii\web\View::POS_END); ?>  

